<template>
  <div id="app">
    <!-- <a-menu :selectedKeys="[currentRoute]" mode="horizontal" theme="dark">
      <a-menu-item 
        v-for="(item) in menus" 
        :key="item.key"
        >
        <router-link :to="item.route">{{item.title}}</router-link>
      </a-menu-item>
     </a-menu> -->
    <div style="color: red">从主应用接受的登录信息: {{ loginType }}</div>
    <router-view :key="(new Date()).getTime()" />
  </div>
</template>

<script>
// import actions from "@/shared/actions";

export default {
  name: 'App',
  data() {
    return {
      menus: [
        {
          key: "sass",
          route: "/",
          title: "主页"
        },
        {
          key: "sass-list",
          route: "/list",
          title: "列表页"
        },
        {
          key: "vue-communication",
          route: "/communication",
          title: "通讯页"
        },
      ],
      loginType: '',
    }
  },
  computed: {
    currentRoute() {
      const menu = this.menus.find(item => item.route === this.$route.path)
      return menu ? menu.key : "sass";
    }
  },
  mounted() {
    // actions.onGlobalStateChange(state => {
    //   const { loginType } = state;
    //   if (!loginType) {
    //     this.$message.error("未检测到登录信息！");
    //     return this.$router.push("/");
    //   }
    //   this.loginType = loginType
    //   console.log("从主应用接受的登录信息", loginType);
    // }, true)
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
